package com.major.sort.bubblesorting;

import java.util.Arrays;

public class BubbleSorting {
    public static void bubble(int[] arr) {

        boolean flag = true;
        int temp = 0;
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    flag = false;
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
            if (flag){
                break;
            }else {
                flag = true;
            }
        }

        //System.out.println(Arrays.toString(arr));
    }
}
